from django.shortcuts import render,redirect
from .utils.utils import *
from .routes import routes

from django.http import HttpResponse
from django.views import View



def home_view(request):
    # return render(request, 'home.html', {})
    return redirect('/static/index.html')


def home(request):
    route_list = []
    for sub_routes in routes:
        father_route = {
            "name": sub_routes[0][0],
            "children": []
        }
        for route in sub_routes:
            new_route = {
                "name": route[2],
                "path": route[1],
            }
            father_route['children'].append(new_route)
        route_list.append(father_route)
    return info(route_list) 